package study.test.test.img;

import org.apache.commons.lang.StringUtils;

public class ImgRep {
    public static void main(String[] args) {
        // 路径 替换为动态获取
        String http = "http://localhost/2018-08-08/1533699239199430-430.jpeg";
        // 替换为 ${}
        String path = "D:/home/ubuntu/images/2018-08-08/1533699239199430-430.jpeg";
        String uploadPath = "D:/home/ubuntu/images/";
        String imageHost = "\\$\\{imageHost\\}/";
        path = StringUtils.replace(path, "\\", "/"); // 转换非正则字符串
        path = path.replaceAll("//", "/");
        path = path.replaceAll(uploadPath, imageHost);
        // 把 file 替换为 ${imageHost}
        System.err.println(path);

        // code 中存在的路径 进行反转义 转换成新的http
        String url = "${imageHost}/2018-08-08/1533699239199430-430.jpeg";
        String newUrl = "http://localhost/";
        url = url.replaceAll(imageHost, newUrl);
        // 把 file 替换为 ${imageHost}
        System.err.println(url);

    }

}
